package com.khong.baodizhen.activity;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.ArrayAdapter;
import android.widget.Button;
import android.widget.LinearLayout;
import android.widget.Spinner;

import com.khong.baodizhen.R;

public class DBZHomeActivity extends Activity implements OnClickListener {

	private Spinner taskSpinner;

	private Button startBtn;

	private LinearLayout managerBtn, historyBtn, quaryBtn;

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.dbz_home);

		initView();
		fillData();
	}

	public void initView() {
		taskSpinner = (Spinner) findViewById(R.id.task_spinner);
		startBtn = (Button) findViewById(R.id.btn_start);
		managerBtn = (LinearLayout) findViewById(R.id.btn_manager);
		historyBtn = (LinearLayout) findViewById(R.id.btn_history);
		quaryBtn = (LinearLayout) findViewById(R.id.btn_quary);
	}

	public void fillData() {

		ArrayAdapter adapter = new ArrayAdapter<String>(this,
				android.R.layout.simple_spinner_item, getResources()
						.getStringArray(R.array.spinner_arr));
		adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);

		taskSpinner.setAdapter(adapter);

		startBtn.setOnClickListener(this);
		managerBtn.setOnClickListener(this);
		historyBtn.setOnClickListener(this);
		quaryBtn.setOnClickListener(this);

	}

	@Override
	public void onClick(View v) {
		Intent intent = new Intent();
		switch (v.getId()) {
		case R.id.btn_start:
			intent.setClass(this, DBZCompanyInfoActivity.class);
			startActivity(intent);
			break;
		case R.id.btn_manager:
			intent.setClass(this, DBZManagerPersonActivity.class);
			startActivity(intent);
			break;
		case R.id.btn_history:

			intent.setClass(this, DBZCheckHistoryActivity.class);
			startActivity(intent);
			break;
		case R.id.btn_quary:

			break;
		default:
			break;
		}

	}

}
